package com.hbnu.collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author kittychen
 * @since 2025-10-14 10:15
 */
public class Poker {

    public static void main(String[] args) {
        // 1、定义一个集合，用于存放扑克牌
        List<String> pokers = new ArrayList<>();

        // 2、准备扑克牌
        String[] colorPoker = new String[]{"♥", "♠", "♦", "♣"};
        String[] numberPoker = new String[]{"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};

        // 3、将扑克牌放到容器中
        for (String color : colorPoker) {
            for (String num : numberPoker) {
                pokers.add(color + num);
            }
        }
        pokers.add("🃏King");
        pokers.add("🃏Queen");

        // 4、洗牌
        Collections.shuffle(pokers);
        System.out.println("洗牌：" + pokers);

        // 5、定义集合表示游戏玩家
        List<String> player1 = new ArrayList<>();
        List<String> player2 = new ArrayList<>();
        List<String> player3 = new ArrayList<>();
        List<String> bottom = new ArrayList<>();  // 存放底牌

        // 6、发牌
        for (int i = 0; i < pokers.size(); i++) {
            if (i < 3) {
                bottom.add(pokers.get(i));   // 将前3张牌作为底牌
            } else {
                if (i % 3 == 0) {
                    player1.add(pokers.get(i));
                }
                if (i % 3 == 1) {
                    player2.add(pokers.get(i));
                }

                if (i % 3 == 2) {
                    player3.add(pokers.get(i));
                }
            }
        }

        // 查看所有玩家的牌型
        showPokers("周润发", player1);
        showPokers("周星驰", player2);
        showPokers("刘德华", player3);
        showPokers("底牌", bottom);
    }

    private static void showPokers(String name, List<String> pokers) {
        System.out.print(name + "的牌型：");
        for (String poker : pokers) {
            System.out.print(poker + "\t");
        }
        System.out.println();
    }
}

